package com.zhu.service;

import com.zhu.dao.StudentDao;
import com.zhu.pojo.Student;
import com.zhu.utils.HobbyUtils;

import java.sql.SQLException;
import java.util.List;

public class StudentService {
    private StudentDao studentDao = new StudentDao();
    public List<Student> getStudentList() throws SQLException {
        List<Student> studentList = studentDao.getStudent();
        HobbyUtils.StudentHobby(studentList);
        return studentList;
    }

    public Student getStudentById(int sid){
        Student student = null;
        try {
            student = studentDao.getStudentById(sid);
            HobbyUtils.StudentHobby(student);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return student;
    }

    public static void main(String[] args) {
        Student studentById = new StudentService().getStudentById(1);
        System.out.println(studentById);
    }
}
